#include<bits/stdc++.h>
#define ll long long
#define L x<<1
#define R x<<1|1
#define mid ((l+r)>>1)
#define lc L,l,mid
#define rc R,mid+1,r
#define Root 1,1,n-1
#define OK Ll<=l&&r<=Rr
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define repn(x) rep(x,1,n)
#define repm(x) rep(x,1,m)
#define pb push_back
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define ui unsigned ll
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57) {if(c=='-') w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
inline void pf(ll x){if(x<0) putchar('-'),x=-x;if(x>9)pf(x/10);putchar(x%10+48);}
using namespace std;
const int N=3e5+5,M=1e6+5,inf=(1LL<<29)-1,mod=998244353;
const ll llf=1e18;
inline void add(int &a,int b){((a+=b)>=mod) and (a-=mod);}
inline int Add(int a,int b){return add(a,b),a;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline void red(int &a,int b){add(a,mod-b);}
inline int Red(int a,int b){return red(a,b),a;}
inline int qp(int a,ll b){if(!b)return 1;int c=qp(a,b>>1LL);Mul(c,c);if(b&1)Mul(c,a);return c;}
inline int INV(int x){return qp(x,mod-2);}
bool S;
int n,k,m,a[N],iv,iv2=INV(2);
struct node{
	int x,y;
}b[N];
int f[1505][1505],g[1505][1505];//len,操作 k 次，保持不动的概率
inline int calc2(int x){
	return mul(x,mul(x-1,iv2));
}
inline void prefix(int t){
	repn(i)g[i][t]=Add(g[i-1][t],f[i][t]);
}
inline int gets(int l,int r,int t){
	if(l>r)return 0;
	return Red(g[r][t],g[l-1][t]);
}
int cr[N];//长度为len的逆序对数
inline void del(int l,int r){
	if(l>r)swap(l,r);
	if(a[l]>a[r])cr[r-l+1]--;
}
inline void ins(int l,int r){
	if(l>r)swap(l,r);
	if(a[l]>a[r])cr[r-l+1]++;
}
inline void solve(int l,int r){
	repn(i)if(i!=l&&i!=r)del(i,l),del(i,r);
	del(l,r);
}
inline void insert(int l,int r){
	repn(i)if(i!=l&&i!=r)ins(i,l),ins(i,r);
	ins(l,r);
}
inline void subtask1(){
	iv=INV(calc2(n));
	int pn=n<=3?0:mul(iv,calc2(n-2));
	rep(i,2,n)f[i][0]=1;
	prefix(0);
	rep(t,1,k){
		rep(i,2,n){
			f[i][t]=mul(pn,f[i][t-1]);//先不变
			add(f[i][t],mul(mul(2,iv),gets(2,i-1,t-1)));
			add(f[i][t],mul(iv,gets(i+1,n,t-1)));
			add(f[i][t],mul(iv,Red(n-i,gets(2,n-i+1,t-1))));
			add(f[i][t],mul(iv,Red(1,f[i][t-1])));
		}
		prefix(t);
	}
	int ans=0;
	repn(l)rep(r,l+1,n)if(a[l]>a[r])add(ans,f[r-l+1][k]),cr[r-l+1]++;
	else add(ans,Red(1,f[r-l+1][k]));
	cout <<ans<<'\n';
	repm(i){
		solve(b[i].x,b[i].y);
		swap(a[b[i].x],a[b[i].y]);
		insert(b[i].x,b[i].y);
		int ans=0;
		rep(len,2,n){
			int C=n-len+1;
			add(ans,Add(mul(cr[len],f[len][k-i]),mul(C-cr[len],Red(1,f[len][k-i]))));
		}
		cout <<ans<<'\n';
	}
}
int t[N];
inline void ad(int x){
	while(x<=n)t[x]++,x+=x&-x;
}
inline int query(int x){
	int ans=0;
	while(x)ans+=t[x],x-=x&-x;
	return ans;
}
inline void subtask0(){
	int ans=0;
	repn(i){
		add(ans,query(n-a[i]+1)),ad(n-a[i]+1);
	}
	cout <<ans;
}
int tt[N];
inline void Ad(int x,int k){
	while(x<=n)add(tt[x],k),x+=x&-x;
}
inline int Query(int x){
	int ans=0;
	while(x)add(ans,tt[x]),x-=x&-x;
	return ans;
}
inline void subtask2(){
	iv=INV(calc2(n));
	int ans=0;
	repn(i){
		int Sum=Query(a[i]),c=query(a[i]);//顺序对
		add(ans,mul(iv,Red(Sum,mul(c,i))));
		Ad(a[i],n+i),ad(a[i]);
	}
	repn(i)t[i]=tt[i]=0;
	repn(i){
		int Sum=Query(n-a[i]+1),c=query(n-a[i]+1);//逆序对
		add(ans,Red(c,mul(iv,Red(Sum,mul(c,i)))));
		Ad(n-a[i]+1,n+i),ad(n-a[i]+1);
	}
	cout <<ans<<'\n';
	repn(i)t[i]=0;
	swap(a[b[1].x],a[b[1].y]);
	if(m)subtask0();
}

inline void Main(){
	n=read(),k=read(),m=read();
	repn(i)a[i]=read();
	repm(i)b[i].x=read(),b[i].y=read();
	if(n<=1500&&k<=1500)return subtask1(),void();
	if(k==0)return subtask0(),void();
	if(k==1)return subtask2(),void();
}
bool E;
signed main(){
	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);
	int T=1;
	while(T--)Main();
	return 0;
}